from django.db import models
from apps.api.project.models import ProjectModel
from utils.base_model import BaseModel


class FunctionModel(BaseModel):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=50, verbose_name="该名称", help_text="函数文件")
    content = models.TextField(max_length=20000, verbose_name="辅助函数文件内容", help_text="辅助函数文件内容", blank=True)
    project = models.OneToOneField(to=ProjectModel, on_delete=models.CASCADE, to_field="id",
                                   verbose_name="所属项目id", help_text="所属项目id")
    is_delete = models.IntegerField(verbose_name="逻辑删除(0-未删除、1-删除)", help_text="逻辑删除(0-未删除、1-删除)",
                                    default=0)

    class Meta:
        db_table = "dtp_function"
        verbose_name = "函数文件"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name
